package com.ruoyi.show.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.show.domain.Top10BooksComment;
import com.ruoyi.show.service.ITop10BooksCommentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 最热书籍Controller
 * 
 * @author ruoyi
 * @date 2025-09-08
 */
@RestController
@RequestMapping("/show/popularBook")
public class Top10BooksCommentController extends BaseController
{
    @Autowired
    private ITop10BooksCommentService top10BooksCommentService;

    /**
     * 查询最热书籍列表
     */
    @PreAuthorize("@ss.hasPermi('show:popularBook:list')")
    @GetMapping("/list")
    public TableDataInfo list(Top10BooksComment top10BooksComment)
    {
        startPage();
        List<Top10BooksComment> list = top10BooksCommentService.selectTop10BooksCommentList(top10BooksComment);
        return getDataTable(list);
    }

    /**
     * 导出最热书籍列表
     */
    @PreAuthorize("@ss.hasPermi('show:popularBook:export')")
    @Log(title = "最热书籍", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Top10BooksComment top10BooksComment)
    {
        List<Top10BooksComment> list = top10BooksCommentService.selectTop10BooksCommentList(top10BooksComment);
        ExcelUtil<Top10BooksComment> util = new ExcelUtil<Top10BooksComment>(Top10BooksComment.class);
        util.exportExcel(response, list, "最热书籍数据");
    }

    /**
     * 获取最热书籍详细信息
     */
    @PreAuthorize("@ss.hasPermi('show:popularBook:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(top10BooksCommentService.selectTop10BooksCommentById(id));
    }

    /**
     * 新增最热书籍
     */
    @PreAuthorize("@ss.hasPermi('show:popularBook:add')")
    @Log(title = "最热书籍", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Top10BooksComment top10BooksComment)
    {
        return toAjax(top10BooksCommentService.insertTop10BooksComment(top10BooksComment));
    }

    /**
     * 修改最热书籍
     */
    @PreAuthorize("@ss.hasPermi('show:popularBook:edit')")
    @Log(title = "最热书籍", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Top10BooksComment top10BooksComment)
    {
        return toAjax(top10BooksCommentService.updateTop10BooksComment(top10BooksComment));
    }

    /**
     * 删除最热书籍
     */
    @PreAuthorize("@ss.hasPermi('show:popularBook:remove')")
    @Log(title = "最热书籍", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(top10BooksCommentService.deleteTop10BooksCommentByIds(ids));
    }
}
